home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 8
/
008.d81
/
roman numbers
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
4KB
|
131 lines
1 poke53265,peek(53265)and247
2 poke53281,3:poke53280,3:print"[144][147]":fori=1to24:printchr$(17);:next
3 poke53265,(peek(53265)and248)+7:print
4 print" roman numbers by m.dombrowski mcmlxxxv";
5 forp=6to0step-1
6 poke53265,(peek(53265)and248)+p
7 forx=1to50:next
8 next:g=g+1:ifg<24then3
9 fort=1to999:next
10 iffl=1then12
11 fl=1:dimc$(25),d%(25),rn$(20)
12 print"[147]":print" there was a time in europe when the roman system of";
13 print" notation was the most popular method of writing numbers."
14 gosub500
15 print"enter r[146] for decimal to roman conversion"
35 print"any key for roman to decimal conversion"
36 printtab(13)"enter q[146] to quit"
40 getmd$:ifmd$="r"thenprint"[147]":gosub500:gosub650
41 ifmd$=""then40
42 ifmd$="q"thenpoke53265,peek(53265)or8:goto63000
43 ifop=0thenrun57
44 printtab(13)""rn$" ="op"[146]":op=0:goto14
45 print"[147]":printtab(5)"the roman notation for numbers":iffl=1then47
46 fl=1:dimc$(25),d%(25),rn$(20)
47 print" two principles are used here to form "spc(8)"numbers with roman";
48 print" numerals: (1)addition, (2)subtraction."
49 printtab(11)"addition principal:"
50 printtab(8)"xxviii = x+x+v+i+i+i = 28"
51 printtab(9)"subtraction principal:"
52 print" is used in writing all[146] fours and nines"
53 print" 4=iv,9=ix,40=xl,90=xc,400=cd,900=cm"
55 printtab(14)"hit any key"
56 getmd$:ifmd$=""then56
57 print"[147]";:gosub500:print" rules:":iffl=1then62
58 fl=1:dimc$(25),d%(25),rn$(20)
62 print" first write the thousands,"
63 print" then the hundreds,";
64 print" then the tens,"
65 print" and last of all, the units"
98 iffl=1then100
99 dimc$(25),d%(25),rn$(20):fl=1
100 a$="":b=0
108 print"enter roman numeral: limit 24 characters"
110 inputa$:b=len(a$)
112 ifb=>25thenrun11
115 fori=1tob
140 c$(i)=mid$(a$,i,1):next
170 fori=1tob:ifc$(i)="m"thend%(i)=1000:next
180 ifc$(i)="d"thend%(i)=500:next
190 ifc$(i)="c"thend%(i)=100:next
200 ifc$(i)="l"thend%(i)=50:next
210 ifc$(i)="x"thend%(i)=10:next
220 ifc$(i)="v"thend%(i)=5:next
230 ifc$(i)="i"thend%(i)=1:next
231 ifb<2then300
232 fori=1tob
233 ifd%(i)<.1*(d%(i+1))thenrun45
234 ifi=b-1then237
235 next
237 ifb<3then300
238 fori=1tob
239 ifd%(i)+d%(i+1)<d%(i+2)thenrun45
240 ifi=b-1then300
241 next
300 fori=1tob:ifd%(i)=0then45
310 ifd%(i)=>d%(i+1)thene%=d%(i):f%=f%+e%:e%=0:goto340
320 ifd%(i)<d%(i+1)thene%=d%(i+1)-d%(i)
330 f%=f%+e%:e%=0:i=i+1
340 next
345 f=f%:gosub700
350 ifa$<>rn$thenrun45
400 printtab(14)""a$" ="f%"[146]":print
445 printtab(11)"another try ? y[146]es"
450 getmd$:ifmd$="y"thenrun57
455 ifmd$=""then450
499 run11
500 printtab(13)"roman numerals":print
510 print" our number roman symbol"
520 print "[163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163]"
530 print" 1.........................i"
540 print" 5.........................v"
550 print" 10.........................x"
560 print" 50.........................l"
570 print" 100.........................c"
580 print" 500.........................d"
590 print" 1000.........................m"
600 print"[164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]"
610 return
650 print" decimal limit: 1-99999 "
655 input"enter decimal number";f:op=f:rn$=""
660 iff<1orf=>100000thenrun11
675 m=0:cm=0:d=0:cd=0:c=0:xc=0:l=0:xl=0:ix=0:iv=0:x=0:v=0:u=0
700 iff<1000then710
702 m=int(f/1000):f=f-m*1000:iff=0then800
710 iff=>900thenf=f-900:cm=1:goto740
712 cm=0:iff=0then800
720 iff=>500thenf=f-500:d=1:goto740
722 d=0:iff=0then800
730 iff=>400thenf=f-400:cd=1:goto740
733 cd=0:iff=0then800
740 iff=>100thenc=int(f/100):f=f-c*100
750 iff=>90thenxc=1:f=f-90:goto780
755 xc=0:iff=0then800
760 iff=>50thenl=1:f=f-50:goto780
766 l=0:iff=0then800
770 iff=>40thenxl=1:f=f-40:goto780
777 xl=0:iff=0then800
780 iff=>10thenx=int(f/10):f=f-x*10
790 iff=9thenix=1:f=f-9
792 iff=>5thenv=1:f=f-5
797 iff=4theniv=1:f=f-4
799 u=f
800 ifm>0thenfori=1tom:rn$=rn$+"m":next
805 ifcm=1thenrn$=rn$+"cm":goto820
810 ifd=1thenrn$=rn$+"d":goto820
815 ifcd=1thenrn$=rn$+"cd":goto820
820 ifc<>0then:fori=1toc:rn$=rn$+"c":next
825 ifxc=1thenrn$=rn$+"xc":goto840
830 ifl=1thenrn$=rn$+"l":goto840
835 ifxl=1thenrn$=rn$+"xl":goto840
840 ifx<>0thenfori=1tox:rn$=rn$+"x":next
845 ifix=1thenrn$=rn$+"ix"
846 ifv=1thenrn$=rn$+"v"
847 ifiv=1thenrn$=rn$+"iv"
848 ifu<>0thenfori=1tou:rn$=rn$+"i":next
850 return
63000 rem connect back to l.s.
63001 poke53265,27: rem fix screen
63002 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
63004 poke198,0:poke631,13:poke632,13:poke198,2:end